package com.project.server.service.broadroom.impl;

import com.project.common.core.domain.BaseServer;
import com.project.server.domain.broadroom.TBroadroom;
import com.project.server.mapper.broadroom.TBroadroomBookMapper;
import com.project.server.mapper.broadroom.TBroadroomMapper;
import com.project.server.service.broadroom.ITBroadroomService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 会议室信息Service业务层处理
 *
 * @author project
 */
@Service
public class TBroadroomServiceImpl extends BaseServer implements ITBroadroomService {

    private static final Logger log = LoggerFactory.getLogger(TBroadroomServiceImpl.class);

    @Resource
    private TBroadroomMapper tBroadroomMapper;

    @Resource
    private TBroadroomBookMapper tBroadroomBookMapper;

    /**
     * 查询会议室信息
     *
     * @param broadroomId 会议室信息ID
     * @return 会议室信息
     */
    @Override
    public TBroadroom selectTBroadroomById(Long broadroomId) {
        return tBroadroomMapper.selectTBroadroomById(broadroomId);
    }

    /**
     * 查询会议室信息列表
     *
     * @param tBroadroom 会议室信息
     * @return 会议室信息
     */
    @Override
    public List<TBroadroom> selectTBroadroomList(TBroadroom tBroadroom) {

        return tBroadroomMapper.selectTBroadroomList(tBroadroom);
    }


    /**
     * 新增会议室信息
     *
     * @param tBroadroom 会议室信息
     * @return 结果
     */
    @Override
    public int insertTBroadroom(TBroadroom tBroadroom) {
        TBroadroom tBroadroom1 = new TBroadroom();
        tBroadroom1.setBroadroomName(tBroadroom.getBroadroomName());
        tBroadroom1.setBroadroomAddress(tBroadroom.getBroadroomAddress());
        List<TBroadroom> broadrooms = tBroadroomMapper.selectTBroadroomByBroadroomName(tBroadroom1);
        if (broadrooms.size() > 0) {
            return 0;
        }
        super.insert(tBroadroom);
        return tBroadroomMapper.insertTBroadroom(tBroadroom);


    }

    /**
     * 修改会议室信息
     *
     * @param tBroadroom 会议室信息
     * @return 结果
     */
    @Override
    public int updateTBroadroom(TBroadroom tBroadroom) {
        super.update(tBroadroom);
        return tBroadroomMapper.updateTBroadroom(tBroadroom);
    }

    /**
     * 批量删除会议室信息
     *
     * @param broadroomIds 需要删除的会议室信息ID
     * @return 结果
     */
    @Override
    public int deleteTBroadroomByIds(Long[] broadroomIds) {
        return tBroadroomMapper.deleteTBroadroomByIds(broadroomIds);
    }

    /**
     * 删除会议室信息信息
     *
     * @param broadroomId 会议室信息ID
     * @return 结果
     */
    @Override
    public int deleteTBroadroomById(Long broadroomId) {
        return tBroadroomMapper.deleteTBroadroomById(broadroomId);
    }


}
